import { createApp } from 'vue'

// element-plus
// import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
// import zhCn from 'element-plus/es/locale/lang/zh-cn'
import * as ElIconModules from '@element-plus/icons-vue'

import filter from '@/utils/fitters'
import util from '@haluo/util'
import { loadJs, loadCss } from '@/utils/index'
// global css
import './styles/index.scss'
import 'vite-plugin-svg-icons/register'
import svgIcon from './components/SvgIcon/index.vue'

import App from './App.vue'
import router from './router'
import store from './store'

import './permission' // permission control
window.loadJs = loadJs
window.loadCss = loadCss

const app = createApp(App)

// 统一注册Icon图标
for (const iconName in ElIconModules) {
  if (Reflect.has(ElIconModules, iconName)) {
    const item = ElIconModules[iconName]
    app.component(iconName, item)
  }
}

app.use(router).use(store).mount('#app')
// 注册全局svg组件
app.component('SvgIcon', svgIcon)

app.config.globalProperties.$filter = { ...filter, ...util }

export default app
